﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Csla.Data;
using Sireass.Dal;
using log4net;

namespace Sireass.DalSql
{
    public class NombreValorDal : INombreValorDal
    {

		// Create a logger for use in this class
		private static readonly ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

		private SqlParameter paramTabla = null;
        private string nombreProcedimiento = null;

        public NombreValorDal()
        {
            paramTabla = new SqlParameter("@Tabla", System.Data.SqlDbType.VarChar);
			paramTabla.Direction = System.Data.ParameterDirection.Input;
            nombreProcedimiento = "spSireassNombreValor";
        }

        public System.Data.IDataReader Fetch(string tabla)
        {
		  paramTabla.Value = tabla;
          using (var ctx = ConnectionManager<SqlConnection>.GetManager("SqlServer"))
          {
            var cm = ctx.Connection.CreateCommand();
            cm.CommandType = System.Data.CommandType.StoredProcedure;
            cm.CommandText = nombreProcedimiento;
            cm.Parameters.Add(paramTabla);
            return cm.ExecuteReader();
          }
        }

        
  }
}
